from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base


class DbConfig:
    # 对象的基类
    Base = declarative_base()
    # 初始化数据库连接
    engine = create_engine('mysql+pymysql://root:Mysqlroot@localhost:3306/waimaiyuan')
    # 创建DBSession类型
    DBSession = sessionmaker(bind=engine)


def get_base():
    return DbConfig.Base


def get_eng():
    return DbConfig.engine


def get_db_session():
    return DbConfig.DBSession
